<template>
	<div class="tab-control">
		<div class="tab-control-item" v-for="item in title" :key="item.id" :class="{active:currentIndex === item.id}" @click="tabClick(item.id)">
			<span>{{item.name}}</span>
		</div>
	</div>
</template>

<script>
	export default {
		name: "TabControl",
		props: {
			title: {
				type: Array,
				default () {
					return []
				}
			}
		},
		data() {
			return {
				currentIndex: 1
			}
		},
		methods: {
			tabClick(index) {
				this.currentIndex = index;
				this.$emit('tabClick', index);
			}
		}
	}
</script>
<style lang="less">
	.tab-control {
		display: flex;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		background-color: #fff;
		font-size: 24rpx;
		.tab-control-item {
			flex: 1;
		}
	}
	.active span {
		padding: 8rpx;
		color:  #e57768;
		border-bottom: 4rpx solid #e57768;
	}
</style>
